package com.dzu.easy;

/**
 * @author ZhaoDong
 * @date 2022/10/10 10:02
 * @description 657. 机器人能否返回原点
 */
public class Test657 {

    public static void main(String[] args) {
        System.out.println(judgeCircle("UD"));
    }
    public static boolean judgeCircle(String moves) {

        int x = 0;
        int y = 0;
        for (char c : moves.toCharArray()) {
            if (c == 'R') {
                x++;
            }
            if (c == 'L') {
                x--;
            }
            if (c == 'U') {
                y++;
            }
            if (c == 'D') {
                y--;
            }
        }
        return x == 0 && y == 0;
    }
}
